package edu.ahut.corejava3;

import java.util.Iterator;
import java.util.List;
import java.util.Vector;

public class IteratorDemo {
    public static void main(String[] args) {
        List<Integer> list = new Vector<Integer>();

        for (int i = 0; i < 10; i++) {
            list.add(i);

        }


        Iterator<Integer> it = list.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() + "  ");
        }
        System.out.println();


        //for each 是迭代器模式的一种简化 （语法糖）
        for (Integer each : list) {
            System.out.println(each + " ");
        }


    }
}
